40fcefb38OTgsUKHBpwshLLIsiIaCA tools/sv/images/middle-no-highlight.jpg
40fcefb32SPtrw36c4S6YGFlLvkKuw tools/sv/images/orb_01.jpg
40fcefb3Ok5qkX3iM7ZEPVkRInrUpg tools/sv/images/orb_02.jpg
+4104ffca9_GhWOxRE-83uZIad2Z1gg tools/sv/images/pause.png
41013a82ILk71xLqWFH5ZO5VmOIvBw tools/sv/images/reboot.png
40fcefb3JnT5XeKTuVF4yUMGOtuNZg tools/sv/images/right-end-highlight.jpg
40fcefb3-DuYOS7noo2W7b_0p7TOUg tools/sv/images/right-end-no-highlight.jpg
40fcefb3dgsa24WLk_BJeYQHrDLuOg tools/sv/images/seperator-right-highlight.jpg
40fcefb3FtiX4Pd2kT8wDlp8u8xRhQ tools/sv/images/seperator.jpg
41013a82sUdUqBv8EoAUJii3gsZ-4g tools/sv/images/shutdown.png
+4104ffca-jPHLVOrW0n0VghEXXtKxg tools/sv/images/unpause.png
40fcefb3yMSrZvApO9ToIi-iQwnchA tools/sv/images/xen.png
41013a83z27rKvWIxAfUBMVZ1eDCDg tools/sv/inc/script.js
40fcefb3zGC9XNBkSwTEobCoq8YClA tools/sv/inc/style.css
self.dom = dom[0]
GenTabbed.write_BODY( self, request )
+
+ def write_MENU( self, request ):
+ pass
class DomGeneralTab( CompositeTab ):
def __init__( self ):
class DomActionTab( ActionTab ):
def __init__( self ):
- ActionTab.__init__( self, { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ),
- "reboot" : ( "Reboot the Domain", "reboot.png" ) } )
+ actions = { "shutdown" : ( "Shutdown the Domain", "shutdown.png" ),
+ "reboot" : ( "Reboot the Domain", "reboot.png" ),
+ "pause" : ( "Pause the Domain", "pause.png" ),
+ "unpause" : ( "Unpause the Domain", "unpause.png" ) }
+ ActionTab.__init__( self, actions )
def op_shutdown( self, request ):
- print ">DomShutDown"
+ dom = getVar( 'dom', request )
+ if not dom is None:
+ print ">DomShutDown %s" % dom
#server.xend_node_shutdown()
def op_reboot( self, request ):
- print ">DomReboot"
+ dom = getVar( 'dom', request )
+ if not dom is None:
+ print ">DomReboot %s" % dom
#server.xend_node_reboot()
+ def op_pause( self, request ):
+ dom = getVar( 'dom', request )
+ if not dom is None:
+ print ">DomPause %s" % dom
+ server.xend_domain_pause( int( dom ) )
+
+ def op_unpause( self, request ):
+ dom = getVar( 'dom', request )
+ if not dom is None:
+ print ">DomUnpause %s" % dom
+ server.xend_domain_unpause( int( dom ) )
+
+
+
+
def __init__( self, urlWriter ):
HTMLBase.__init__(self)
self.urlWriter = urlWriter
+
+ def write_MENU( self, request ):
+ return self.write_BODY( request, head=True, long=False )
def write_BODY( self, request, head=True, long=True ):
request.write( "<td class='domainInfo' align='center'><a href='%s'>%s</a></td>\n" % ( url, domInfoHash['name'] ) )
if long:
- request.write( "<td class='domainInfo' align='center'>%(mem)7d</td>\n" % domInfoHash )
- request.write( "<td class='domainInfo' align='center'>%(cpu)3d</td>\n" % domInfoHash )
+ request.write( "<td class='domainInfo' align='center'>%(memory)5s</td>\n" % domInfoHash )
+ request.write( "<td class='domainInfo' align='center'>%(cpu)2s</td>\n" % domInfoHash )
request.write( "<td class='domainInfo' align='center'>%(state)5s</td>\n" % domInfoHash )
- if long:
- request.write( "<td class='domainInfo' align='center'>%(cpu_time)7.1f</td>\n" % domInfoHash )
def write_DOMAIN_HEAD( self, request, long=True ):
request.write( "<td class='domainInfoHead' align='center'>Domain</td>\n" )
request.write( "<td class='domainInfoHead' align='center'>Memory / Mb</td>\n" )
request.write( "<td class='domainInfoHead' align='center'>CPU</td>\n" )
request.write( "<td class='domainInfoHead' align='center'>State</td>\n" )
- if long:
- request.write( "<td class='domainInfoHead' align='center'>CPU time / s</td>\n" )
request.write( " <td width='15px'> </td>" )
request.write( " <td width='175px' align='center' valign'center'>" )
request.write( " <table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'>" )
- request.write( " <tr><td height='200px' align='center' valign='center'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" )
- request.write( " <img src='images/xen.png' width='150' height='75' border='0'/></a></td></tr>" )
+ request.write( " <tr><td height='140px' align='center' valign='bottom'><a href='http://www.cl.cam.ac.uk/Research/SRG/netos/xen/'>" )
+ request.write( " <img src='images/xen.png' width='150' height='75' border='0'/></a><br/></td></tr>" )
+ request.write( " <tr><td height='60px' align='center'><p class='small'>SV Web Interface<br/>(C) <a href='mailto:tw275@cam.ac.uk'>Tom Wilkie</a> 2004</p></td></tr>")
request.write( " <tr><td align='center' valign='top'>" )
for (modName, (modTitle, module)) in self.modules.items():
- request.write( " <p class='small'><a href='Main.rpy?mod=%s'>%s</a></p>" % (modName, modTitle))
-
- DomList( self.mainUrlWriter ).write_BODY( request, True, False )
+ module( self.mainUrlWriter ).write_MENU( request )
request.write( " </td></tr>" )
request.write( " </table>" )
return urlWriter( "mod=node%s" % url )
GenTabbed.__init__( self, "Node Details", newUrlWriter, [ 'General', 'Dmesg', ], [ NodeGeneralTab, NodeDmesgTab ] )
+
+ def write_MENU( self, request ):
+ request.write( "<p class='small'><a href='%s'>Node details</a></p>" % self.urlWriter( '' ) )
class NodeGeneralTab( CompositeTab ):
def __init__( self ):
from xen.xend import sxp
from xen.xend import PrettyPrint
+import types
+
def getDomInfoHash( domain ):
- domInfo = server.xend_domain( int( domain ) )
- d = {}
- d['dom'] = int( domain )
- d['name'] = sxp.child_value( domInfo, 'name' )
- d['mem'] = int( sxp.child_value( domInfo, 'memory' ) )
- d['cpu'] = int( sxp.child_value( domInfo, 'cpu' ) )
- d['state'] = sxp.child_value( domInfo, 'state' )
- d['cpu_time'] = float( sxp.child_value( domInfo, 'cpu_time' ) )
- if( sxp.child_value( domInfo, 'up_time' ) ):
- d['up_time'] = float( sxp.child_value( domInfo, 'up_time' ) )
- if( sxp.child_value( domInfo, 'start_time' ) ):
- d['start_time'] = float( sxp.child_value( domInfo, 'start_time' ) )
- return d
+ domInfoHash = sxp2hash( server.xend_domain( int( domain ) ) )
+ domInfoHash['dom'] = int( domain )
+ return domInfoHash
def sxp2hash( s ):
sxphash = {}
for child in sxp.children( s ):
- sxphash[ child[0] ] = child[1]
+ if child is types.ListType:
+ sxphash[ child[0] ] = sxp2hash( child[1] )
+ else:
+ sxphash[ child[0] ] = child[1]
return sxphash
self.str = self.str + str
temp = tmp()
PrettyPrint.prettyprint( sxp, out=temp )
- return temp.str
+ return temp.str
+
+def getVar( var, request ):
+
+ arg = request.args.get( var )
+
+ if arg is None or len(arg) != 1:
+ return None
+ else:
+ return arg[0]
def bigTimeFormatter( time ):
+ time = float( time )
weeks = time // 604800
remainder = time % 604800
days = remainder // 86400
return "%d weeks, %d days, %s" % ( weeks, days, hms )
def smallTimeFormatter( time ):
+ time = float( time )
hours = time // 3600
remainder = time % 3600
mins = remainder // 60
def stateFormatter( state ):
states = [ 'Running', 'Blocked', 'Paused', 'Shutdown', 'Crashed' ]
+ stateStr = ""
+
for i in range( len( state ) ):
if state[i] != "-":
- return states[ i ] + " (%s)" % state
-
- return state
-
+ stateStr += "%s, " % states[ i ]
+
+ return stateStr + " (%s)" % state
+
def memoryFormatter( mem ):
mem = int( mem )
if mem >= 1024:
return "%7dMb" % mem
def cpuFormatter( mhz ):
+ mhz = int( mhz )
if mhz > 1000:
ghz = float( mhz ) / 1000.0
return "%4.2fGHz" % ghz
install -m0644 images/shutdown.png $(sv_insdir)/images
install -m0644 images/reboot.png $(sv_insdir)/images
+ install -m0644 images/pause.png $(sv_insdir)/images
+ install -m0644 images/unpause.png $(sv_insdir)/images
# make include folder
mkdir -p $(sv_insdir)/inc